package com.zhixing.myboot.service.impl;

import com.zhixing.myboot.dao.UserInfoMapper;
import com.zhixing.myboot.framework.core.AbstractService;
import com.zhixing.myboot.model.UserInfo;
import com.zhixing.myboot.service.UserInfoService;
import org.apache.ibatis.exceptions.TooManyResultsException;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Condition;

import javax.annotation.Resource;
import java.util.List;


/**
 * @author shuimo
 * @version 2017/11/17
 */
@Service
@Transactional
@CacheConfig(cacheNames = {"cache"})
public class UserInfoServiceImpl extends AbstractService<UserInfo> implements UserInfoService {

    @Resource
    private UserInfoMapper userInfoMapper;

    @Override
    public void save(UserInfo model) {
        super.save(model);
    }

    @Override
    public void save(List<UserInfo> models) {
        super.save(models);
    }

    @Override
    @CacheEvict(key = "'UserInfo:' + #id")
    public void deleteById(Integer id) {
        super.deleteById(id);
    }

    @Override
    public void deleteByIds(String ids) {
        super.deleteByIds(ids);
    }

    @Override
    @CachePut(key = "'UserInfo:' + #model.id")
    public void update(UserInfo model) {
        super.update(model);
    }

    @Override
    @Cacheable(key = "'UserInfo:' + #id")
    public UserInfo findById(Integer id) {
        return super.findById(id);
    }

    @Override
    public UserInfo findBy(String fieldName, Object value) throws TooManyResultsException {
        return super.findBy(fieldName, value);
    }

    @Override
    public List<UserInfo> findByIds(String ids) {
        return super.findByIds(ids);
    }

    @Override
    public List<UserInfo> findByCondition(Condition condition) {
        return super.findByCondition(condition);
    }

    @Override
    public List<UserInfo> findAll() {
        return super.findAll();
    }

}
